package com.feibiao.computer;

import java.util.Scanner;

public class FactoryPatternComputor {
    public static void main(String[] args) {

        double result = 0;
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入运算符+、-、*、/、^、！");
        String operator = scanner.next();
        if (operator.equals("+") || operator.equals("-") ||operator.equals("*") ||operator.equals("/") ||operator.equals("^")){
            AbstractFactory twoOperandComputeFactory = FactoryProducer.getFactory(operator);
            TwoOperandCompute twoOperandCompute1 = twoOperandComputeFactory.getTwoOperandCompute(operator);
             result = twoOperandCompute1.compute();
        }else if(operator.equals("!")){
            AbstractFactory oneOperandComputeFactory = FactoryProducer.getFactory(operator);
            OneOperandCompute oneOperandCompute1 = oneOperandComputeFactory.getOneOperandCompute(operator);
             result = oneOperandCompute1.compute();
        }
        System.out.println("运算结果是：" + result);

    }
}
